package or.exa.cangguan.utils;

import cn.hutool.core.lang.UUID;
import lombok.Data;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Data
@Component
public class OrderUtil {


    public String generateOrderNo(String prefix_NO) {
        LocalDateTime now = LocalDateTime.now();
        String date = now.format(DateTimeFormatter.ofPattern("yyyyMMdd"));
        String generateSuffix = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 6).toUpperCase();
        return prefix_NO + date + generateSuffix;
    }



}